<?php
/**
 * Created by PhpStorm.
 * User: coolinmind
 * Date: 21/01/2019
 * Time: 11:59
 */

namespace App\Modules\UCenter;


use App\Services\UCenter\UCenterIndex;

class Car extends BaseUcenter
{
    /**
     * 车主添加车辆
     * @return array
     */
    public function addCars()
    {
        $userInfo = $this->isLogin();
        if ($userInfo['status'] !== SUCCESS_STATUS) {
            return need_login($userInfo,'请登录');
        }
        $data = $this->postData;
        $data['user_id'] = $userInfo['res']['id'];
        return UCenterIndex::Car()->addCars($data);
    }

    public function changeCarInfo()
    {
        $userInfo = $this->isLogin();
        if ($userInfo['status'] !== SUCCESS_STATUS) {
            return need_login($userInfo,'请登录');
        }
        $data = $this->postData;
        $data['user_id'] = $userInfo['res']['id'];
        return UCenterIndex::Car()->changeCarInfo($data);
    }

    /**
     * 获取车辆列表
     * @return array
     */
    public function getCarList()
    {
        $userInfo = $this->isLogin();
        if ($userInfo['status'] !== SUCCESS_STATUS) {
            return need_login($userInfo,'请登录');
        }
        $data = $this->postData;
        $data['user_id'] = $userInfo['res']['id'];
        return UCenterIndex::Car()->getCarList($data);
    }

    /**
     * 根据id删除车辆信息
     * @return array
     */
    public function delCarById()
    {
        $userInfo = $this->isLogin();
        if ($userInfo['status'] !== SUCCESS_STATUS) {
            return need_login($userInfo,'请登录');
        }
        $data = $this->postData;
        $data['user_id'] = $userInfo['res']['id'];
        return UCenterIndex::Car()->delCarById($data);
    }

    /**
     * 根据id获取车辆详情
     * @return array
     */
    public function getCarById()
    {
        $userInfo = $this->isLogin();
        if ($userInfo['status'] !== SUCCESS_STATUS) {
            return need_login($userInfo,'请登录');
        }
        $data = $this->postData;
        $data['user_id'] = $userInfo['res']['id'];
        return UCenterIndex::Car()->getCarById($data);
    }

    /**
     * 管理员获取车辆列表
     */
    public function backCarList(){
        $userInfo = $this->isLogin();
        if ($userInfo['status'] !== SUCCESS_STATUS) {
            return need_login($userInfo,'请登录');
        }
        $data = $this->postData;
        return UCenterIndex::Car()->backCarList($data);
    }

    /**
     * 管理员获取车辆详情
     * @return array
     */
    public function backCarInfo()
    {
        $data = $this->postData;
        return UCenterIndex::Car()->backCarInfo($data);
    }

    /**
     * 管理员审核车辆
     * @return array
     */
    public function backCarAudit()
    {
        $data = $this->postData;
        return UCenterIndex::Car()->backCarAudit($data);
    }
}
